<template>
  <div>
    <!--列表-->
    <el-table
      ref="table"
      v-loading="tableLoad"
      :data="tableData"
      fit
      highlight-current-row
      @selection-change="handleSelectionChange"
    >
      <el-table-column type="selection" width="55" />
      <el-table-column prop="sampleNum" label="样品编号"> </el-table-column>
      <el-table-column prop="sampleName" label="样品名称"> </el-table-column>
      <el-table-column prop="sampleModel" label="产品型号"> </el-table-column>
      <el-table-column prop="detectionItemName" label="检测项目" />
      <el-table-column prop="sampleCount" label="送样数量" />
      <el-table-column prop="sampleCollectionCount" label="领取数量" />
      <el-table-column
        prop="sampleCollectionDate"
        label="领取日期"
        :formatter="formatTableTime"
      />
      <el-table-column prop="permissionUserName" label="领取人" />
    </el-table>
  </div>
</template>
<script>
import { formatTime } from "../../../utils/time";
// import { getList } from "../../../api/SampleManage/SampleCollection";
import { getListWaitDo } from "../../../api/SampleManage/SampleStore";

export default {
  name: "SampleStoreCommission",
  components: {},
  props: {
    filterForm: {
      type: Object,
      default: () => {},
    },
    pageInfo: {
      type: Object,
      default: () => {},
    },
  },
  data() {
    return {
      dialogFormVisible: false,
      loading: false,
      pagination: {
        pageIndex: 1,
        pageSize: 10,
        total: 0,
      },
      tableLoad: false,
      tableData: [],
      tableDatas: [],
    };
  },
  computed: {},
  watch: {
    loadState(val) {
      if (val) {
        this.getList();
      }
    },
  },
  created() {
    this.getList();
  },
  methods: {
    formatTableTime(row) {
      if (
        row.sampleCollectionDate !== null &&
        row.sampleCollectionDate !== ""
      ) {
        return formatTime(row.sampleCollectionDate);
      }
    },
    // 关闭样品接收dialog
    closeSampleReceivingDialog() {
      this.rowData = [];
      this.getList();
    },

    handleSelectionChange(val) {
      this.tableDatas = val;
    },
    getList(flag) {
      this.loading = true;
      getListWaitDo({ ...this.filterForm, ...this.pageInfo })
        .then((res) => {
          this.tableData = res.data.dataList ? res.data.dataList : [];
          this.$emit("update:total", res.data.total);
          this.loading = false;
        })
        .catch(() => {
          this.loading = false;
        });
    },
  },
};
</script>
